package com.equis.architecture.preloader {
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.ProgressEvent;
	
	import mx.events.FlexEvent;
	import mx.preloaders.DownloadProgressBar;
	
	public class EquisPreloader extends DownloadProgressBar {
	
		public static const initHandler:EventDispatcher = new EventDispatcher();
		
		protected function get dataPercentage():Number {
			return 20;
		}
		
		protected function swfLoadProgress(percentage:Number):Number {
			var ret:Number = percentage * ((100 - dataPercentage) / 100);
			return Math.round(ret);
		}
	
		protected function dataLoadProgress(percentage:Number):Number {
			var ret:Number = (100 - dataPercentage) + (percentage * (dataPercentage / 100));
			return Math.round(ret);
		}
	    
	    protected function onFlexInitComplete(event:FlexEvent):void {
			initHandler.addEventListener(Event.COMPLETE, onDataInitComplete);
			initHandler.addEventListener(ProgressEvent.PROGRESS, onDataProgress);
	    }
	
		protected function onDataProgress(event:ProgressEvent):void {
			
		}
	
	    protected function onDataInitComplete(event:Event):void {
	        dispatchEvent(new Event(Event.COMPLETE));
	    }
	}
}